package ai4games_tests.tests;

import g4p_controls.G4P;
import g4p_controls.GAlign;
import g4p_controls.GCScheme;
import g4p_controls.GEvent;
import g4p_controls.GImageButton;
import g4p_controls.GLabel;
import g4p_controls.GPanel;
import g4p_controls.GSlider;
import game2dai.Domain;
import game2dai.World;
import game2dai.entities.BaseEntity;
import game2dai.entities.Vehicle;
import game2dai.entityshapes.ps.PicturePS;
import game2dai.maths.Vector2D;
import game2dai.steering.AutoPilot;
import game2dai.utils.StopWatch;
import processing.core.PApplet;

public class TestFlocking extends PApplet {
	float wanderDist, wanderRadius, wanderJitter;
	float initWander = 1.0f, initFlock = 16.0f;
	float initAlign = 8.0f, initCohesion = 2.2f, initSeparation = 1.3f;
	float initWanderJitter = 6.0f, initWanderRadius = 30, initWanderDist = 100;
	float initMaxSpeed = 70.0f, initNeighbourhood = 50.0f;

	final int NBR_BOIDS = 200;

	World w;
	Domain wd;
	StopWatch sw = new StopWatch();

	Vehicle boid;
	Vehicle[] boids;
	AutoPilot sb;
	AutoPilot[] sbarray;
	BoidPic view;
	float deltaTime;
	int backcol, boidcol;
	long count = 0;

	public void setup() {
		size(620, 700);
		createGUI();

		w = new World(width, height, 67, 10);
		wd = new Domain(10, 30, 610, 630);
		w.noOverlap(true);

		view = new BoidPic(this, 8, color(220, 220, 255));	
		setColors(1);


		sb = new AutoPilot();
		sb.wanderOn().flockOn();
		sb.wanderFactors(initWanderDist, initWanderRadius, initWanderJitter);
		sb.flockFactors(50);
		sb.wanderWeight(initWander);
		sb.alignmentWeight(initAlign);
		sb.cohesionWeight(initCohesion);
		sb.separationWeight(initSeparation);
		sb.flockWeight(initFlock);

		boids = new Vehicle[NBR_BOIDS];
		sbarray = new AutoPilot[NBR_BOIDS];
		for (int i = 0; i < NBR_BOIDS; i++) {
			float dirX = (rnd(0, 1) < 0.5) ? -1 : 1;
			float dirY = (rnd(0, 1) < 0.5) ? -1 : 1;
			float x = dirX * rnd(5, 10);
			float y = dirY * rnd(5, 10);
			boid = new Vehicle(new Vector2D(), // position
					5, // collision radius
					new Vector2D(), // velocity
					initMaxSpeed, // maximum speed (was 60)
					new Vector2D(), // heading
					1, // mass
					5, // turning rate
					400 // max force
			); 
			boid.renderer(view);
			boids[i] = boid;
			sbarray[i] = (AutoPilot) sb.clone();
			boid.AP(sbarray[i]);
			boid.worldDomain(wd);
			w.add(boid);
		}
		restartBoids();
		frameRate(1000);
		sw.reset();
	}


	public void draw() {
		deltaTime = (float) sw.getElapsedTime();
		background(0);
		fill(backcol);
		rect((float)wd.lowX, (float)wd.lowY, (float)wd.width, (float)wd.height);

		//  fill(0, 64, 0);
		//  noStroke();

		w.update(deltaTime);
		w.draw();

		fill(201, 206, 255);
		noStroke();
		rect(0, 640, width, height-640);

		if (++count % 100 == 0) {
			lblFPSvalue.setText(""+frameRate);
			lblCalcTimeValue.setText(""+ (float)w.worldUpdateTime + " s");
		}
	}

	//	public void changeWeighting(int type, float value) {
	//	  for (int i = 0; i < NBR_BOIDS; i++) 
	//	    sbarray[i].setWeight(type, value);
	//	}

	public void changeWander() {
		for (int i = 0; i < NBR_BOIDS; i++) 
			sbarray[i].wanderFactors(wanderDist, wanderRadius, wanderJitter);
	}

	public void changeNeighbourhood(float radius) {
		for (int i = 0; i < NBR_BOIDS; i++) 
			sbarray[i].flockFactors(radius);
	}

	public void changeMaxSpeed(float radius) {
		for (int i = 0; i < NBR_BOIDS; i++) 
			boids[i].maxSpeed(radius);
	}

	public void restartBoids() {
		for (int i = 0; i < NBR_BOIDS; i++) {
			  boids[i].die(w, 0);
//			    w.remove(boids[i]);
			float x = (width - 200)/2 + random(-150, 150);
			float y = height/2 + random(-150, 150);
			float dirX = (rnd(0, 1) < 0.5) ? -1 : 1;
			float dirY = (rnd(0, 1) < 0.5) ? -1 : 1;
			float vx = dirX * rnd(5, 10);
			float vy = dirY * rnd(5, 10);
			boids[i].moveTo(x, y);
			boids[i].heading(vx, vy);
			boids[i].velocity(vx, vy);
			w.add(boids[i]);
		}
	}

	public float rnd(float low, float high) {
		return (float)Math.random()*(high - low) + low;
	}

	public void setColors(int cols) {
		switch(cols) {
		case 2:
			backcol = color(32, 32, 0);
			boidcol = color(0, 255, 0); 
			break;
		case 3:
			backcol = color(200, 255, 200);
			boidcol = color(0); 
			break;
		case 4:
			backcol = color(255, 255, 200);
			boidcol = color(255, 0, 0); 
			break;
		default:
			backcol = color(0, 0, 64);
			boidcol = color(220, 220, 255);
		};
		view.setFill(boidcol);
	}

	// Boid Class
	class BoidPic extends PicturePS	{
		float arrowLength = 20;
		float[] x = new float[] {
				0.5f * arrowLength, -0.4f * arrowLength, -0.4f * arrowLength
		};
		float[] y = new float[] {
				0, 0.3f * arrowLength, -0.3f * arrowLength
		};

		int fillCol;

		BoidPic(PApplet app) {
			super(app);
		}

		BoidPic(PApplet app, float length, int fill) {
			super(app);
			fillCol = fill;
			arrowLength = length;
			x = new float[] {
					0.5f * arrowLength, -0.4f * arrowLength, -0.4f * arrowLength
			};
			y = new float[] {
					0, 0.3f * arrowLength, -0.3f * arrowLength
			};
		}

		public void draw( BaseEntity owner, float posX, float posY, float velX, float velY, 
				float headX, float headY) {
			float angle = PApplet.atan2(headY, headX);

			pushMatrix();
			translate(posX, posY);
			rotate(angle);

			// Draw arrow head
			fill(fillCol);
			beginShape(PApplet.TRIANGLES);
			vertex(x[0], y[0]);
			vertex(x[1], y[1]);
			vertex(x[2], y[2]);
			endShape(PApplet.CLOSE);
			popMatrix();
		}

		void setFill(int col) {
			fillCol = col;
		}

	}

	// GUI

	/* =========================================================
	 * ====                   WARNING                        ===
	 * =========================================================
	 * The code in this tab has been generated from the GUI form
	 * designer and care should be taken when editing this file.
	 * Only add/edit code inside the event handlers i.e. only
	 * use lines between the matching comment tags. e.g.

	 void myBtnEvents(GButton button) { //_CODE_:button1:12356:
	     // It is safe to enter your event code here  
	 } //_CODE_:button1:12356:

	 * Do not rename this tab!
	 * =========================================================
	 */

	public void btnSteering_click(GImageButton source, GEvent event) { //_CODE_:btnSteering:692200:
		sdrWander.setValue(initWander);
		sdrFlocking.setValue(initFlock);
	} //_CODE_:btnSteering:692200:

	public void sdrWander_change(GSlider source, GEvent event) { //_CODE_:sdrWander:352006:
		lblWander.setText(source.getValueS());
		for (AutoPilot sb : sbarray) 
			sb.wanderWeight(source.getValueF());
	} //_CODE_:sdrWander:352006:

	public void sdrFlocking_change(GSlider source, GEvent event) { //_CODE_:sdrFlocking:544667:
		lblFlocking.setText(source.getValueS());
		for (AutoPilot sb : sbarray) 
			sb.flockWeight(source.getValueF());
	} //_CODE_:sdrFlocking:544667:

	public void btnFlocking_click(GImageButton source, GEvent event) { //_CODE_:btnFlocking:827562:
		sdrAlign.setValue(initAlign);
		sdrCohesion.setValue(initCohesion);
		sdrSeparation.setValue(initSeparation);
	} //_CODE_:btnFlocking:827562:

	public void sdrAlign_change(GSlider source, GEvent event) { //_CODE_:sdrAlign:866362:
		lblAlign.setText(source.getValueS());
		for (AutoPilot sb : sbarray) 
			sb.alignmentWeight(source.getValueF());
	} //_CODE_:sdrAlign:866362:

	public void sdrCohesion_change(GSlider source, GEvent event) { //_CODE_:sdrCohesion:698280:
		lblCohesion.setText(source.getValueS());
		for (AutoPilot sb : sbarray) 
			sb.cohesionWeight(source.getValueF());
	} //_CODE_:sdrCohesion:698280:

	public void sdrSeparation_change(GSlider source, GEvent event) { //_CODE_:sdrSeparation:228893:
		lblSeparation.setText(source.getValueS());
		for (AutoPilot sb : sbarray) 
			sb.separationWeight(source.getValueF());
	} //_CODE_:sdrSeparation:228893:

	public void btnWander_click(GImageButton source, GEvent event) { //_CODE_:btnWander:698063:
		sdrJitter.setValue(initWanderJitter);
		sdrRadius.setValue(initWanderRadius);
		sdrDistance.setValue(initWanderDist);
	} //_CODE_:btnWander:698063:

	public void btnBoid_click(GImageButton source, GEvent event) { //_CODE_:btnBoid:543089:
		sdrSpeed.setValue(initMaxSpeed);
		sdrNeighbourhood.setValue(initNeighbourhood);
	} //_CODE_:btnBoid:543089:

	public void sdrJitter_change(GSlider source, GEvent event) { //_CODE_:sdrJitter:766954:
		wanderJitter = source.getValueF();
		lblJitter.setText(source.getValueS());
		changeWander();
	} //_CODE_:sdrJitter:766954:

	public void sdrRadius_change(GSlider source, GEvent event) { //_CODE_:sdrRadius:629877:
		wanderRadius = source.getValueF();
		lblRadius.setText(source.getValueS());
		changeWander();
	} //_CODE_:sdrRadius:629877:

	public void sdrDistance_change(GSlider source, GEvent event) { //_CODE_:sdrDistance:934854:
		wanderDist = source.getValueF();
		lblDistance.setText(source.getValueS());
		changeWander();
	} //_CODE_:sdrDistance:934854:

	public void sdrSpeed_change(GSlider source, GEvent event) { //_CODE_:sdrSpeed:489772:
		lblSpeed.setText(source.getValueS());
		changeMaxSpeed(source.getValueF());
	} //_CODE_:sdrSpeed:489772:

	public void sdrNeighbourhood_change(GSlider source, GEvent event) { //_CODE_:sdrNeighbourhood:934178:
		lblNeighbourhood.setText(source.getValueS());
		changeNeighbourhood(source.getValueF());
	} //_CODE_:sdrNeighbourhood:934178:

	public void btnColour1_click(GImageButton source, GEvent event) { //_CODE_:btnColour1:327664:
		setColors(1);
	} //_CODE_:btnColour1:327664:

	public void btnColour2_click(GImageButton source, GEvent event) { //_CODE_:btnColour2:494670:
		setColors(2);
	} //_CODE_:btnColour2:494670:

	public void btnColour3_click(GImageButton source, GEvent event) { //_CODE_:btnColour3:303208:
		setColors(3);
	} //_CODE_:btnColour3:303208:

	public void btnColour4_click(GImageButton source, GEvent event) { //_CODE_:btnColour4:638495:
		setColors(4);
	} //_CODE_:btnColour4:638495:

	public void btnRestart_click(GImageButton source, GEvent event) { //_CODE_:btnRestart:448021:
		restartBoids();
	} //_CODE_:btnRestart:448021:



	// Create all the GUI controls. 
	// autogenerated do not edit
	public void createGUI(){
		G4P.messagesEnabled(false);
		G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
		G4P.setCursor(ARROW);
		if(frame != null)
			frame.setTitle("Sketch Window");
		pnlTweaks = new GPanel(this, 0, 0, 290, 540, " Option (click to open/close)           ");
		pnlTweaks.setDraggable(false);
		pnlTweaks.setText(" Option (click to open/close)           ");
		pnlTweaks.setTextBold();
		pnlTweaks.setOpaque(true);
		pnlTweaks.addEventHandler(this, "");
		label1 = new GLabel(this, 10, 20, 250, 20);
		label1.setText("Steering Weights");
		label1.setTextBold();
		label1.setOpaque(false);
		btnSteering = new GImageButton(this, 260, 20, 20, 20, new String[] { "ai4g/reset.png", "ai4g/reset.png", "ai4g/reset.png" } );
		btnSteering.addEventHandler(this, "btnSteering_click");
		label2 = new GLabel(this, 10, 40, 190, 20);
		label2.setText("Wander");
		label2.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label2.setOpaque(false);
		lblWander = new GLabel(this, 200, 40, 80, 20);
		lblWander.setText("1.0");
		lblWander.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblWander.setOpaque(false);
		sdrWander = new GSlider(this, 10, 60, 270, 20, 10.0f);
		sdrWander.setLimits(1.0f, 0.5f, 3.0f);
		sdrWander.setEasing(8.0f);
		sdrWander.setNumberFormat(G4P.DECIMAL, 1);
		sdrWander.setOpaque(false);
		sdrWander.addEventHandler(this, "sdrWander_change");
		label4 = new GLabel(this, 10, 80, 190, 20);
		label4.setText("Flocking");
		label4.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label4.setOpaque(false);
		lblFlocking = new GLabel(this, 200, 80, 80, 20);
		lblFlocking.setText("16.0");
		lblFlocking.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblFlocking.setOpaque(false);
		sdrFlocking = new GSlider(this, 9, 100, 270, 20, 10.0f);
		sdrFlocking.setLimits(16.0f, 1.0f, 30.0f);
		sdrFlocking.setEasing(8.0f);
		sdrFlocking.setNumberFormat(G4P.DECIMAL, 1);
		sdrFlocking.setOpaque(false);
		sdrFlocking.addEventHandler(this, "sdrFlocking_change");
		label6 = new GLabel(this, 10, 130, 250, 20);
		label6.setText("Flocking Weights");
		label6.setTextBold();
		label6.setOpaque(false);
		btnFlocking = new GImageButton(this, 260, 130, 20, 20, new String[] { "ai4g/reset.png", "ai4g/reset.png", "ai4g/reset.png" } );
		btnFlocking.addEventHandler(this, "btnFlocking_click");
		label7 = new GLabel(this, 10, 150, 190, 20);
		label7.setText("Alignment");
		label7.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label7.setOpaque(false);
		lblAlign = new GLabel(this, 200, 150, 80, 20);
		lblAlign.setText("8.0");
		lblAlign.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblAlign.setOpaque(false);
		sdrAlign = new GSlider(this, 10, 170, 270, 20, 10.0f);
		sdrAlign.setLimits(8.0f, 1.0f, 30.0f);
		sdrAlign.setEasing(8.0f);
		sdrAlign.setNumberFormat(G4P.DECIMAL, 1);
		sdrAlign.setOpaque(false);
		sdrAlign.addEventHandler(this, "sdrAlign_change");
		label9 = new GLabel(this, 10, 190, 190, 20);
		label9.setText("Cohesion");
		label9.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label9.setOpaque(false);
		lblCohesion = new GLabel(this, 200, 190, 80, 20);
		lblCohesion.setText("2.2");
		lblCohesion.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblCohesion.setOpaque(false);
		sdrCohesion = new GSlider(this, 10, 210, 270, 20, 10.0f);
		sdrCohesion.setLimits(2.2f, 0.5f, 10.0f);
		sdrCohesion.setEasing(8.0f);
		sdrCohesion.setNumberFormat(G4P.DECIMAL, 1);
		sdrCohesion.setOpaque(false);
		sdrCohesion.addEventHandler(this, "sdrCohesion_change");
		label11 = new GLabel(this, 10, 230, 190, 20);
		label11.setText("Separation");
		label11.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label11.setOpaque(false);
		lblSeparation = new GLabel(this, 200, 230, 80, 20);
		lblSeparation.setText("1.3");
		lblSeparation.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblSeparation.setOpaque(false);
		sdrSeparation = new GSlider(this, 10, 250, 270, 20, 10.0f);
		sdrSeparation.setLimits(1.3f, 0.5f, 10.0f);
		sdrSeparation.setEasing(8.0f);
		sdrSeparation.setNumberFormat(G4P.DECIMAL, 1);
		sdrSeparation.setOpaque(false);
		sdrSeparation.addEventHandler(this, "sdrSeparation_change");
		label13 = new GLabel(this, 10, 280, 250, 20);
		label13.setText("Wander Variables");
		label13.setTextBold();
		label13.setOpaque(false);
		label14 = new GLabel(this, 10, 300, 190, 20);
		label14.setText("Max. Jitter (rad/s)");
		label14.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label14.setOpaque(false);
		lblJitter = new GLabel(this, 200, 300, 80, 20);
		lblJitter.setText("6.0");
		lblJitter.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblJitter.setOpaque(false);
		btnWander = new GImageButton(this, 260, 280, 20, 20, new String[] { "ai4g/reset.png", "ai4g/reset.png", "ai4g/reset.png" } );
		btnWander.addEventHandler(this, "btnWander_click");
		btnBoid = new GImageButton(this, 260, 430, 20, 20, new String[] { "ai4g/reset.png", "ai4g/reset.png", "ai4g/reset.png" } );
		btnBoid.addEventHandler(this, "btnBoid_click");
		sdrJitter = new GSlider(this, 10, 320, 270, 20, 10.0f);
		sdrJitter.setLimits(6.0f, 1.0f, 20.0f);
		sdrJitter.setEasing(8.0f);
		sdrJitter.setNumberFormat(G4P.DECIMAL, 1);
		sdrJitter.setOpaque(false);
		sdrJitter.addEventHandler(this, "sdrJitter_change");
		lable1 = new GLabel(this, 10, 340, 190, 20);
		lable1.setText("Radius");
		lable1.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		lable1.setOpaque(false);
		lblRadius = new GLabel(this, 200, 340, 80, 20);
		lblRadius.setText("30.0");
		lblRadius.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblRadius.setOpaque(false);
		sdrRadius = new GSlider(this, 10, 360, 270, 20, 10.0f);
		sdrRadius.setLimits(30.0f, 10.0f, 60.0f);
		sdrRadius.setEasing(8.0f);
		sdrRadius.setNumberFormat(G4P.DECIMAL, 1);
		sdrRadius.setOpaque(false);
		sdrRadius.addEventHandler(this, "sdrRadius_change");
		label18 = new GLabel(this, 10, 380, 190, 20);
		label18.setText("Distance");
		label18.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label18.setOpaque(false);
		lblDistance = new GLabel(this, 200, 380, 80, 20);
		lblDistance.setText("100.0");
		lblDistance.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblDistance.setOpaque(false);
		sdrDistance = new GSlider(this, 10, 400, 270, 20, 10.0f);
		sdrDistance.setLimits(100.0f, 20.0f, 200.0f);
		sdrDistance.setEasing(8.0f);
		sdrDistance.setNumberFormat(G4P.DECIMAL, 1);
		sdrDistance.setOpaque(false);
		sdrDistance.addEventHandler(this, "sdrDistance_change");
		label20 = new GLabel(this, 10, 430, 250, 20);
		label20.setText("Boid Variables");
		label20.setTextBold();
		label20.setOpaque(false);
		label21 = new GLabel(this, 10, 450, 190, 20);
		label21.setText("Maximum speed");
		label21.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label21.setOpaque(false);
		lblSpeed = new GLabel(this, 200, 450, 80, 20);
		lblSpeed.setText("70.0");
		lblSpeed.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblSpeed.setOpaque(false);
		sdrSpeed = new GSlider(this, 10, 470, 270, 20, 10.0f);
		sdrSpeed.setLimits(70.0f, 20.0f, 150.0f);
		sdrSpeed.setEasing(8.0f);
		sdrSpeed.setNumberFormat(G4P.DECIMAL, 1);
		sdrSpeed.setOpaque(false);
		sdrSpeed.addEventHandler(this, "sdrSpeed_change");
		label23 = new GLabel(this, 10, 490, 190, 20);
		label23.setText("Neighbourhood radius");
		label23.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
		label23.setOpaque(false);
		lblNeighbourhood = new GLabel(this, 200, 490, 80, 20);
		lblNeighbourhood.setText("50.0");
		lblNeighbourhood.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblNeighbourhood.setOpaque(false);
		sdrNeighbourhood = new GSlider(this, 10, 510, 270, 20, 10.0f);
		sdrNeighbourhood.setLimits(50.0f, 30.0f, 150.0f);
		sdrNeighbourhood.setEasing(8.0f);
		sdrNeighbourhood.setNumberFormat(G4P.DECIMAL, 1);
		sdrNeighbourhood.setOpaque(false);
		sdrNeighbourhood.addEventHandler(this, "sdrNeighbourhood_change");
		pnlTweaks.addControl(label1);
		pnlTweaks.addControl(btnSteering);
		pnlTweaks.addControl(label2);
		pnlTweaks.addControl(lblWander);
		pnlTweaks.addControl(sdrWander);
		pnlTweaks.addControl(label4);
		pnlTweaks.addControl(lblFlocking);
		pnlTweaks.addControl(sdrFlocking);
		pnlTweaks.addControl(label6);
		pnlTweaks.addControl(btnFlocking);
		pnlTweaks.addControl(label7);
		pnlTweaks.addControl(lblAlign);
		pnlTweaks.addControl(sdrAlign);
		pnlTweaks.addControl(label9);
		pnlTweaks.addControl(lblCohesion);
		pnlTweaks.addControl(sdrCohesion);
		pnlTweaks.addControl(label11);
		pnlTweaks.addControl(lblSeparation);
		pnlTweaks.addControl(sdrSeparation);
		pnlTweaks.addControl(label13);
		pnlTweaks.addControl(label14);
		pnlTweaks.addControl(lblJitter);
		pnlTweaks.addControl(btnWander);
		pnlTweaks.addControl(btnBoid);
		pnlTweaks.addControl(sdrJitter);
		pnlTweaks.addControl(lable1);
		pnlTweaks.addControl(lblRadius);
		pnlTweaks.addControl(sdrRadius);
		pnlTweaks.addControl(label18);
		pnlTweaks.addControl(lblDistance);
		pnlTweaks.addControl(sdrDistance);
		pnlTweaks.addControl(label20);
		pnlTweaks.addControl(label21);
		pnlTweaks.addControl(lblSpeed);
		pnlTweaks.addControl(sdrSpeed);
		pnlTweaks.addControl(label23);
		pnlTweaks.addControl(lblNeighbourhood);
		pnlTweaks.addControl(sdrNeighbourhood);
		btnColour1 = new GImageButton(this, 10, 650, 40, 40, new String[] { "ai4g/boidcol1.png", "ai4g/boidcol1.png", "ai4g/boidcol1.png" } );
		btnColour1.addEventHandler(this, "btnColour1_click");
		btnColour2 = new GImageButton(this, 90, 650, 40, 40, new String[] { "ai4g/boidcol2.png", "ai4g/boidcol2.png", "ai4g/boidcol2.png" } );
		btnColour2.addEventHandler(this, "btnColour2_click");
		btnColour3 = new GImageButton(this, 50, 650, 40, 40, new String[] { "ai4g/boidcol3.png", "ai4g/boidcol3.png", "ai4g/boidcol3.png" } );
		btnColour3.addEventHandler(this, "btnColour3_click");
		btnColour4 = new GImageButton(this, 130, 650, 40, 40, new String[] { "ai4g/boidcol4.png", "ai4g/boidcol4.png", "ai4g/boidcol4.png" } );
		btnColour4.addEventHandler(this, "btnColour4_click");
		btnRestart = new GImageButton(this, 460, 650, 150, 40, new String[] { "ai4g/boidreset.png", "ai4g/boidreset.png", "ai4g/boidreset.png" } );
		btnRestart.addEventHandler(this, "btnRestart_click");
		label25 = new GLabel(this, 190, 650, 110, 20);
		label25.setText("Frame Rate");
		label25.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		label25.setOpaque(false);
		label26 = new GLabel(this, 330, 650, 120, 20);
		label26.setText("Calculation time (s)");
		label26.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		label26.setOpaque(false);
		lblFPSvalue = new GLabel(this, 190, 670, 110, 20);
		lblFPSvalue.setText(" ");
		lblFPSvalue.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblFPSvalue.setOpaque(false);
		lblCalcTimeValue = new GLabel(this, 330, 670, 120, 20);
		lblCalcTimeValue.setText(" ");
		lblCalcTimeValue.setTextAlign(GAlign.RIGHT, GAlign.MIDDLE);
		lblCalcTimeValue.setOpaque(false);
	}

	// Variable declarations 
	// autogenerated do not edit
	GPanel pnlTweaks; 
	GLabel label1; 
	GImageButton btnSteering; 
	GLabel label2; 
	GLabel lblWander; 
	GSlider sdrWander; 
	GLabel label4; 
	GLabel lblFlocking; 
	GSlider sdrFlocking; 
	GLabel label6; 
	GImageButton btnFlocking; 
	GLabel label7; 
	GLabel lblAlign; 
	GSlider sdrAlign; 
	GLabel label9; 
	GLabel lblCohesion; 
	GSlider sdrCohesion; 
	GLabel label11; 
	GLabel lblSeparation; 
	GSlider sdrSeparation; 
	GLabel label13; 
	GLabel label14; 
	GLabel lblJitter; 
	GImageButton btnWander; 
	GImageButton btnBoid; 
	GSlider sdrJitter; 
	GLabel lable1; 
	GLabel lblRadius; 
	GSlider sdrRadius; 
	GLabel label18; 
	GLabel lblDistance; 
	GSlider sdrDistance; 
	GLabel label20; 
	GLabel label21; 
	GLabel lblSpeed; 
	GSlider sdrSpeed; 
	GLabel label23; 
	GLabel lblNeighbourhood; 
	GSlider sdrNeighbourhood; 
	GImageButton btnColour1; 
	GImageButton btnColour2; 
	GImageButton btnColour3; 
	GImageButton btnColour4; 
	GImageButton btnRestart; 
	GLabel label25; 
	GLabel label26; 
	GLabel lblFPSvalue; 
	GLabel lblCalcTimeValue; 

}
